<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>indexOfAll</title>
</head>
<body>
    <h1>[1,3,4,5,4],中查找4，返回索引数组:</h1>
    <div id="content"></div>
    <script>
        const indexOfAll = (arr,val) => arr.reduce((acc,item,i) => (item === val ? [...acc,i] : acc),[]);
        document.querySelector("#content").innerHTML = `查找到的索引数组为:${ indexOfAll([1,3,4,5,4],4)}`;
    </script>
</body>
</html>